import { createRouter, createWebHistory, RouteRecordRaw } from "vue-router"
import Layout from '@/layout/Index.vue'
import Login from '../views/login/Index.vue'

const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        // 将根路径重定向到登录页面
        redirect: '/login'
    },
    {
        path: '/login',
        name: 'login',
        component: Login,
        meta: {
            title: '登录'
        }
    },
    {
        path: '/',
        component: Layout,
        children:[
            {
                path: '/advertisement',
                name: 'advertisement',
                component: ()=> import('../views/advertisement/Index.vue'),
                meta:{
                    title:'广告管理'
                }
            },
            {
                path: '/category',
                name: 'category',
                component: ()=> import('@/views/category/Index.vue'),
                meta:{
                    title:'菜品分类'
                }
            },
            {
                path: '/comment',
                name: 'comment',
                component: ()=> import('../views/comment/Index.vue'),
                meta:{
                    title:'评论管理'
                }
            },
            {
                path: '/goods',
                name: 'goods',
                component: ()=> import('../views/goods/Index.vue'),
                meta:{
                    title:'菜品管理'
                }
            },
            {
                path: '/order',
                name: 'order',
                component: ()=> import('../views/order/Index.vue'),
                meta:{
                    title:'订单管理'
                }
            },
            {
                path: '/user',
                name: 'user',
                component: ()=> import('../views/user/Index.vue'),
                meta:{
                    title:'用户管理'
                }
            },
        ]
    },
]

const router = createRouter({
    history: createWebHistory(),
    routes,
})

export default router

